<?php
/*
Plugin Name: Synergy Help
Plugin URI: http://
Description: Help wordpress plugin for Synergy Resource management system.
Author: Weranga Kaluarachchi
Version: 1.0
Author URI: http://ditio.net
*/


function widget_syn_help() {
?>
	
<?php

echo $before_widget; 
global $wpdb;

	echo "<h4>Help</h4>\n";
	$result = $wpdb->get_results("SELECT TITLE, TEXT FROM {$wpdb->prefix}help ORDER BY id"); 
	foreach ($result as $r) {
		echo "<div class='helpTitle'>$r->TITLE</div>\n";
		echo "<div class='helpText'>$r->TEXT</div>\n";
	}

	echo $after_widget; 
}

register_sidebar_widget('Help', 'widget_syn_help');


function syn_help_install()
{
    global $wpdb;
    $table = $wpdb->prefix."help";
	
	$structure = "DROP TABLE IF EXISTS $table;";
    //$wpdb->query($structure);

    $structure = "CREATE TABLE $table (
        id INT(9) NOT NULL AUTO_INCREMENT,
        TITLE VARCHAR(100) NOT NULL,
        TEXT VARCHAR(1000) NOT NULL,
        DATE DATETIME,
        UNIQUE KEY id (id)
    );";
    
    $wpdb->query($structure);
 
}
add_action('activate_syn_help/syn_help.php', 'syn_help_install');
?>